package priv.pront.code.national.acwing.dp.bags;

import java.util.Scanner;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-05-09 12:38
 */
public class Acwing8_二维费用的背包问题 {

    static int N, V, M;
    static int[][] dp;
    static int[] v, m, w;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        V = scanner.nextInt();
        M = scanner.nextInt();
        dp = new int[V + 1][M + 1];
        v = new int[N + 1];
        m = new int[N + 1];
        w = new int[N + 1];
        for(int i = 1; i <= N; i ++){
            v[i] = scanner.nextInt();
            m[i] = scanner.nextInt();
            w[i] = scanner.nextInt();
        }

        for(int i = 1; i <= N; i++){
            for(int j = V; j >= v[i]; j--){
                for(int k = M; k >= m[i]; k--){
                    dp[j][k] = Math.max(dp[j][k], dp[j - v[i]][k - m[i]] + w[i]);
                }
            }
        }
        System.out.println(dp[V][M]);
    }
}
